var options1 = {
    thumbBox: '.thumbBox',
    spinner: '.spinner',
    imgSrc: ''
}
var cropper = $('.imageBox').cropbox(options1);
$('#upload-file').on('change', function () {

    var reader = new FileReader();
    reader.onload = function (e) {
        options1.imgSrc = e.target.result;
        cropper = $('.imageBox').cropbox(options1);
    }
    reader.readAsDataURL(this.files[0]);
})
$('#btnCrop').on('click', function () {
    var img = cropper.getDataURL();
    $('.cropped').html('');
    $('.cropped').append('<img src="' + img + '" align="absmiddle" style="width:64px;margin-top:4px;border-radius:64px;box-shad' +
        'ow:0px 0px 12px #7E7E7E;" ><p>64px*64px</p>');
    $('.cropped').append('<img src="' + img + '" align="absmiddle" style="width:128px;margin-top:4px;border-radius:128px;box-sh' +
        'adow:0px 0px 12px #7E7E7E;"><p>128px*128px</p>');
    $('.cropped').append('<img src="' + img + '" align="absmiddle" style="width:180px;margin-top:4px;border-radius:180px;box-sh' +
        'adow:0px 0px 12px #7E7E7E;"><p>180px*180px</p>');
})
$('#btnZoomIn').on('click', function () {
    cropper.zoomIn();
})
$('#btnZoomOut').on('click', function () {
    cropper.zoomOut();
})
$('#change-button').click(function () {
    var img = cropper.getDataURL();
     $.ajax({
         type: "post",
         url: "/User/ChangeUserAvatar",   
         data: {
             "": img //这里是传给后台
         },
         success: function (result) {
             
             window.location.href = "/User/PersonalHomepage";
         },
         error: function (msg) {
             alert("上传失败！");
            
         }
     });

})